#pragma once

class CScene;
class BMP;
class CRenderer
{
public:
	CRenderer(void);
	virtual ~CRenderer(void);

	void Init();
	void Render(CScene* pScene);
	void UpdateFrame();

	const unsigned char* GetFrameBuffer() const { return m_pFrameBuffer; }
	DATA_TYPE* GetDepthBuffer() { return m_pDepthBuffer; }

	vector<CVector4>& GetWorldPositions() { return m_vWorldPositions; }
	vector<CVector4>& GetTransformedPositions() { return m_vTransformedPositions; }
	vector<CVector4>& GetColors() { return m_vColors; }
	vector<CVector4>& GetNormals() { return m_vNormals; }
	vector<CVector4>& GetTextureUVs() { return m_vTextureUVs; }

	bool ZTest(int iIndex, DATA_TYPE fValue);

protected:
	void SetupMatricesForP1();
	void SetupMatricesForP2();

	void RenderFragment(int iIndex);
	CVector4 SampleTexture(const CVector4& vTextureUV);

	unsigned char* m_pFrameBuffer;
	DATA_TYPE* m_pDepthBuffer;

	BMP* m_pTexture;

public:
	CMatrix4 matView;
	CMatrix4 matProjection;
	CMatrix4 matViewport;

	vector<CVector4> m_vWorldPositions;
	vector<CVector4> m_vTransformedPositions;
	vector<CVector4> m_vColors;
	vector<CVector4> m_vNormals;
	vector<CVector4> m_vTextureUVs;
};

